home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
turbovis
/
fsserial.zip
/
ANSIVIEW.PAS
next >
Wrap
Pascal/Delphi Source File
|
1991-01-29
|
20KB
|
705 lines
Unit AnsiView;
{ ANSIVIEW.PAS - 24 January 1991
By Marcos R. Della
5084 Rincon Ave.
Santa Rosa, CA 95409
CIS: 71675,765
This Unit was written so that I had something that reminded me of the
original WRITELN and WRITE statments of pascal where I was working
with the screen and there were various definate controls I had using
the GOTOXY and CLRSCR routines. Under TVision, you no longer have
these controls and need to learn a completely different way of getting
info on the screen.
AnsiView was written to give you some of these old methods while still
using the TVision platform. That is, your screen is a scroll window of
your size choosing (You can define a screen 128,2048 and use the gotoxy
to get to anywhere on that screen!) Also if you turn on the ANSI
option, the driver will recognise ANSI controls (For reading those ANSI
files directly and displaying them!)
Because this is also a TVision enviroment, your screen will also be
saved if you do a desktop save! Wonderful stuff eh?
NOTE!!! Registration values used by this Unit
TANSIView = 7200;
TInterior = 7201;
--------------------
Modification History
--------------------
29 January 1991 - Added the code to handle 15 of the ANSI control
characters if they are passed to the ANSIView
routines. There are two commands that will no work with this current
implementation. The <ESC>[xP and <ESC>[x@ for insert and delete
characters on the current line. These should be supported in the
near future whenever I get back to working on this unit...
There is a problem with the cursor positioning not always updating
the onscreen cursor display (if you have it on) however with the
printing of any character or other command, it comes back on. I'm
still scratching my head over this one.
}
{$F+,O+,R-,S-}
Interface
Uses Dos, Drivers, Views, Objects, Memory;
CONST MaxViewHeight = 2048;
TYPE PScreenL = ^TScreenL;
TScreenL = ARRAY[0..MaxViewWidth - 1] OF WORD;
PScreenR = ^TScreenR;
TScreenR = ARRAY[0..MaxViewHeight - 1] OF PScreenL;
PInterior = ^TInterior;
TInterior = OBJECT(TScroller)
AutoScroll : BOOLEAN;
MaxDim : TPoint;
CurLoc : TPoint;
TopPtr : PScreenR;
CONSTRUCTOR Init(VAR Bounds : TRect; Limits : TPoint;
Color : BYTE; AHScrollBar, AVScrollBar : PScrollBar);
CONSTRUCTOR Load(VAR S : TStream);
PROCEDURE Store(VAR S : TStream);
PROCEDURE Draw; VIRTUAL;
PROCEDURE PrintChar(Ch : CHAR; VAR TextAttr : BYTE);
DESTRUCTOR Done; VIRTUAL;
END;
ParmsFld = ARRAY[1..9] OF BYTE;
PANSIView = ^TANSIView;
TANSIView = OBJECT(TWindow)
UseANSI : BOOLEAN;
StateInfo : BYTE;
ESCBuf : STRING[126];
ANSIParms : ParmsFld;
ParmsIdx : BYTE;
EndString : CHAR;
CurHold : TPoint;
TextAttr : BYTE;
Interior : PInterior;
CONSTRUCTOR Init(Bounds : TRect; Limits : TPoint; WnTitle : STRING; WindowNo : WORD);
CONSTRUCTOR Load(VAR S : TStream);
PROCEDURE Store(VAR S : TStream);
FUNCTION ProcessChar(Ch : CHAR) : BOOLEAN;
PROCEDURE PrintLN(s : STRING);
PROCEDURE Print(s : STRING);
PROCEDURE PrintChar(Ch : CHAR);
PROCEDURE PutChar(X, Y : WORD; Ch : CHAR; Attr : BYTE);
PROCEDURE CursorOn;
PROCEDURE CursorOff;
PROCEDURE AutoScrollOn;
PROCEDURE AutoScrollOff;
PROCEDURE ClrScr;
PROCEDURE ClrEol;
PROCEDURE DelLine;
PROCEDURE GotoXY(X,Y : WORD);
PROCEDURE HighVideo;
PROCEDURE InsLine;
PROCEDURE LowVideo;
PROCEDURE TextBackground(Color : BYTE);
PROCEDURE TextColor(Color : BYTE);
FUNCTION WhereX : BYTE;
FUNCTION WhereY : WORD;
END;
CONST RANSIView: TStreamRec = (
ObjType: 7200;
VmtLink: Ofs(TypeOf(TANSIView)^);
Load: @TANSIView.Load;
Store: @TANSIView.Store
);
RInterior: TStreamRec = (
ObjType: 7201;
VmtLink: Ofs(TypeOf(TInterior)^);
Load: @TInterior.Load;
Store: @TInterior.Store
);
PROCEDURE RegisterANSIView;
Implementation
{----------------------------------------------------------------------------}
FUNCTION Min(X,Y : INTEGER) : INTEGER; ASSEMBLER;
ASM
MOV AX,X
CMP AX,Y
JLE @@1
MOV AX,Y
@@1:
END;
FUNCTION Max(X,Y : INTEGER) : INTEGER; ASSEMBLER;
ASM
MOV AX,X
CMP AX,Y
JGE @@1
MOV AX,Y
@@1:
END;
{----------------------------------------------------------------------------}
CONSTRUCTOR TInterior.Init;
VAR i,j : WORD;
BEGIN
TScroller.Init(Bounds,AHScrollBar,AVScrollBar);
MaxDim := Limits;
AutoScroll := TRUE;
CurLoc.X := 0;
CurLoc.Y := 0;
TopPtr := MemAlloc(MaxDim.Y * SIZEOF(PScreenR)); {Allocate All Y Coords}
IF TopPtr = NIL THEN
BEGIN
TScroller.Done;
FAIL
END;
FOR i := 0 TO MaxDim.Y - 1 DO BEGIN {Now for each line}
TopPtr^[i] := MemAlloc(MaxDim.X * SIZEOF(WORD));
IF TopPtr^[i] = NIL THEN
BEGIN
IF i > 0 THEN
FOR j := 0 TO i - 1 DO
FREEMEM(TopPtr^[j],MaxDim.X * SIZEOF(WORD));
FREEMEM(TopPtr,MaxDim.Y * SIZEOF(PScreenR));
TScroller.Done;
FAIL
END
ELSE
MoveChar(TopPtr^[i]^,' ',Color,MaxDim.X)
END;
GrowMode := gfGrowHiX + gfGrowHiY;
DragMode := dmLimitLoX + dmLimitLoY;
SetLimit(MaxDim.X,MaxDim.Y);
END;
CONSTRUCTOR TInterior.Load;
VAR i,j : INTEGER;
ok : BOOLEAN;
B : TDrawBuffer;
BEGIN
TScroller.Load(S);
S.Read(AutoScroll,SIZEOF(AutoScroll));
S.Read(CurLoc,SIZEOF(CurLoc));
S.Read(MaxDim,SIZEOF(MaxDim));
TopPtr := MemAlloc(MaxDim.Y * SIZEOF(PScreenR));
ok := (TopPtr <> NIL);
FOR i := 0 TO MaxDim.Y - 1 DO BEGIN
S.Read(B,MaxDim.X * SIZEOF(WORD));
IF ok THEN
BEGIN
TopPtr^[i] := MemAlloc(MaxDim.X * SIZEOF(WORD));
ok := ok AND (TopPtr^[i] <> NIL);
IF ok THEN
MOVE(B,TopPtr^[i]^,MaxDim.X * SIZEOF(WORD))
ELSE
IF i > 0 THEN
FOR j := 0 TO i - 1 DO
FREEMEM(TopPtr^[j],MaxDim.X * SIZEOF(WORD));
END
END;
IF NOT ok THEN
BEGIN
FREEMEM(TopPtr,MaxDim.Y * SIZEOF(PScreenR));
TScroller.Done;
FAIL
END;
GrowMode := gfGrowHiX + gfGrowHiY;
SetLimit(MaxDim.X,MaxDim.Y)
END;
PROCEDURE TInterior.Store;
VAR i : INTEGER;
BEGIN
TScroller.Store(S);
S.Write(AutoScroll,SIZEOF(AutoScroll));
S.Write(CurLoc,SIZEOF(CurLoc));
S.Write(MaxDim,SIZEOF(MaxDim));
FOR i := 0 TO MaxDim.Y - 1 DO
S.Write(TopPtr^[i]^,MaxDim.X * SIZEOF(WORD));
END;
PROCEDURE TInterior.Draw;
VAR Y : INTEGER;
BEGIN
FOR Y := 0 TO Size.Y - 1 DO
WriteLine(0,Y,Size.X,1,TopPtr^[Delt